﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
</head>
<body>
	<script>
		function Solve() {
			var number = parseInt(arguments[0]);
			return generateKas(number);
		}

		function generateKas(input) {
			// Generate Numbers map
			var map = [];
			var i = 0;
			for (var ch = "A".charCodeAt(0) ; ch <= "Z".charCodeAt(0) ; ch++, i++) {
				map[i] = String.fromCharCode(ch);
			}

			var leadingCh = "a".charCodeAt(0);
			while (i < 256) {
				for (var ch = "A".charCodeAt(0); ch <= "Z".charCodeAt(0); ch++) {
					if (i < 256) {
						map[i] = String.fromCharCode(leadingCh) + String.fromCharCode(ch);
						i++;
					}
					else { break; }
				}
				leadingCh++;
			}
			console.log(map);
			
			// Get Kas numbers
			var remainder = Math.floor(input % 256);
			var whole = Math.floor(input / 256);
			var result = [];
			result[0] = '';
			do {
				result.pop(map[remainder]);
				remainder = Math.floor(whole % 256);
				whole = Math.floor(whole / 256);
			}
			while (remainder > 0);
			result.pop(map[whole]);

			return result.join('');
		}

		console.log(Solve(255));
	</script>
</body>
</html>
